﻿using System;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.nodes.mysql;

namespace SharpSqlAnalyzer.stmt.mysql
{
	// Token: 0x02000159 RID: 345
	public class TMySQLPrepareStmt : TCustomSqlStatement
	{
		// Token: 0x06000BAE RID: 2990 RVA: 0x0030670C File Offset: 0x0030490C
		public TMySQLPrepareStmt(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstmysqlprepare;
		}

		// Token: 0x17000223 RID: 547
		// (get) Token: 0x06000BAF RID: 2991 RVA: 0x0030672B File Offset: 0x0030492B
		// (set) Token: 0x06000BB0 RID: 2992 RVA: 0x00306733 File Offset: 0x00304933
		public virtual TCustomSqlStatement PreparableStmt
		{
			get
			{
				return this.preparableStmt;
			}
			set
			{
				this.preparableStmt = value;
			}
		}

		// Token: 0x17000224 RID: 548
		// (get) Token: 0x06000BB1 RID: 2993 RVA: 0x0030673C File Offset: 0x0030493C
		// (set) Token: 0x06000BB2 RID: 2994 RVA: 0x00306744 File Offset: 0x00304944
		public virtual string PreparableStmtStr
		{
			get
			{
				return this.preparableStmtStr;
			}
			set
			{
				this.preparableStmtStr = value;
			}
		}

		// Token: 0x17000225 RID: 549
		// (get) Token: 0x06000BB3 RID: 2995 RVA: 0x0030674D File Offset: 0x0030494D
		// (set) Token: 0x06000BB4 RID: 2996 RVA: 0x00306755 File Offset: 0x00304955
		public virtual TObjectName StmtName
		{
			get
			{
				return this.stmtName;
			}
			set
			{
				this.stmtName = value;
			}
		}

		// Token: 0x06000BB5 RID: 2997 RVA: 0x00306760 File Offset: 0x00304960
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			base.doParseStatement(psql);
			TMySQLPrepareSqlNode tmySQLPrepareSqlNode = (TMySQLPrepareSqlNode)this.rootNode;
			this.stmtName = tmySQLPrepareSqlNode.StmtName;
			if (tmySQLPrepareSqlNode.PreparableStmt.getvalueToken().tokencode == 262)
			{
				this.preparableStmtStr = tmySQLPrepareSqlNode.PreparableStmt.ToString().Replace("'", "");
				this.parser = new TGSharpSqlParser(EDbVendor.dbvmysql);
				this.parser.sqltext = this.preparableStmtStr;
				if (this.parser.parse() == 0)
				{
					this.preparableStmt = this.parser.sqlstatements.get(0);
				}
			}
			return 0;
		}

		// Token: 0x06000BB6 RID: 2998 RVA: 0x00306811 File Offset: 0x00304A11
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x06000BB7 RID: 2999 RVA: 0x00306821 File Offset: 0x00304A21
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			if (this.preparableStmt != null)
			{
				this.preparableStmt.accept(v);
			}
			v.postVisit(this);
		}

		// Token: 0x040012BD RID: 4797
		private TCustomSqlStatement preparableStmt;

		// Token: 0x040012BE RID: 4798
		private TObjectName stmtName;

		// Token: 0x040012BF RID: 4799
		private string preparableStmtStr = "";

		// Token: 0x040012C0 RID: 4800
		internal new TGSharpSqlParser parser;
	}
}
